package cn.tedu.stock.contrller;

import cn.tedu.stock.service.StockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import result.JsonResult;

@RestController
@Slf4j
public class StockController {
    @Autowired
    private StockService stockService;

    //提供一个对外的库存减少功能
    @PostMapping("/stock/reduce")
    public JsonResult reduceStock(@RequestParam("productCode") String productCode,
                                  @RequestParam("count") Integer count) {
        stockService.reduceStock(productCode, count);
        return JsonResult.ok("库存减少成功");
    }
}
